public class homeworkdatetime {
}
package Displaytime;
        import java.util.*;
        import java.text.*;
        import java.io.IOException;
        import java.io.PrintWriter;
        import java.text.SimpleDateFormat;

        import javax.servlet.ServletException;
        import javax.servlet.ServletResponse;
        import javax.servlet.annotation.WebServlet;
        import javax.servlet.http.HttpServlet;
        import javax.servlet.http.HttpServletRequest;
        import javax.servlet.http.HttpServletResponse;

        import org.apache.catalina.connector.Response;

@WebServlet("/displaytime")
public class displaytime extends HttpServlet {
    private static final long serialVersionUID = 1L;

    /**
     * @see HttpServlet#HttpServlet()
     */
    public displaytime() {
        super();
        // TODO Auto-generated constructor stub
    }

    /**
     * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
        response.setContentType("text/html;charset=utf-8");//设置服务器返回页面编码方式
        PrintWriter out = response.getWriter();
        Date datetime = new Date(System.currentTimeMillis());
        SimpleDateFormat time = new SimpleDateFormat("yyyy年MM月dd日-HH时mm分ss秒");
        out.println(time.format(datetime));
    }
    /**
     * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
        doGet(request, response);
    }

    public void destroy() {
        super.destroy();
    }
}

